<template>
    <div class="verification f-cb">
        <div class="verification_title">{{$t('m.openingverification')}}</div>
        <div class="verification_con">
            <span v-if="statusData.legalize_type==3">{{$t('m.text17')}}</span>
            <span v-if="statusData.legalize_type==2">{{$t('m.text18')}}</span>
        </div>
        <ul class="verification_list f-cb" v-if="JSON.stringify(statusData) !='{}'">
            <li>
                <h2 class="ico1">{{$t('m.text16')}}</h2>
                <div class="fonts">
                    <span>{{$t('m.Dataunderreview')}}</span>
                </div>
            </li>
            <li>
                <h2 class="ico2">{{$t('m.text19')}}</h2>
                <div v-if="statusData.legalize_type==2" class="divBox">
                    <div class="BoxTitle">{{$t('m.Verifyidentityonline')}}</div>
                    <p>{{$t('m.text20')}}</p>
                </div>
                <div v-if="statusData.legalize_type==3" class="divBox">
                    <div class="BoxTitle">
                        {{$t('m.Counterverifyidentity')}}
                        <a href="javascript:;" class="fr" @click="changeAddress">{{$t('m.Editlocation')}}</a>
                    </div>
                    <p>{{$t('m.text21')}}</p>
                    <p>{{$t('m.Estimatedwitnesstime')}}：{{parseTime(statusData.appointment.appoint_date,'{y}/{m}/{d}')}}　{{statusData.appointment.appoint_time}}</p>
                    <p>{{$t('m.Addresss')}}：{{statusData.appointment.scenes['name_'+lang]}}{{statusData.appointment.scenes['area_'+lang]}}{{statusData.appointment.scenes['content_'+lang]}}</p>
                    <p>{{$t('m.Telephone')}} : {{statusData.appointment.scenes.mobile_zh}}</p>
                    <p>{{$t('m.Email')}} : {{statusData.appointment.scenes.email}}</p>
                    <p>{{$t('m.BusinessHours')}}: {{statusData.appointment.scenes['business_remark_'+lang]}}</p>
                </div>
            </li>
        </ul>
        <div class="mainLandBtns f-cb">
            <span class="return" @click="returnLinks">{{$t('m.Previousstep')}}</span>
        </div>
    </div>
</template>
<script>
    import {pageFlow,BtnsFlow,uploads,submit,getsubscript} from "@/common/common";
    export default {
        components: {},
        data() {
            return{
               statusData:{},
            }
        },
        computed:{
            info(){
                return JSON.parse(sessionStorage.getItem('info'))
            },
            lang(){
                //JSON.stringify
                return sessionStorage.getItem("lang")=='zh-CN'?'zh':sessionStorage.getItem("lang")=='zh-TW'?'tc':'en'
            },
            appointment(){
                return JSON.parse(sessionStorage.getItem('appointment'))
            }
        },
        mounted(){
            JSON.stringify
            this.getOpenStatus();
            window.document.title = this.$t('m.indexEnd')
        },
        methods:{
            getLocalTime(nS) {     
                return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');     
            },
            getOpenStatus(){
                var _this = this;
                _this.$axios.get('/open/status')
                .then(res => {
                    if(res.data.code == 1){
                        //status 1:未开户，2已经开户(审核成功)，3待审核，4审核未通过，5待完善
                        if(res.data.data.status == 1 ||res.data.data.status == 5){
                            _this.$router.replace({path:'/documentType'})
                        }else{
                            sessionStorage.setItem('userType',res.data.data.user_type)
                            sessionStorage.setItem('appointment',JSON.stringify(res.data.data.appointment))
                            _this.statusData = res.data.data;
                        }
                       
                    }else if(res.data.code == 401){
                        _this.$router.replace({path:'/'})
                    }else if(res.data.code == 102 || res.data.code == 103){
                        _this.$router.replace({path:'/examine'})
                    }else if(res.data.code == 104){
                        _this.$router.go(0)
                    }else{
                        _this.$message({
                            message: res.data.msg,
                            type: "warning"
                        });
                    }
                    
                })
                .catch(function(error) {
                    console.log(error)
                })
            },
            parseTime(time, cFormat) {
                const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
                let date
                if (typeof time === 'undefined' || time === null || time === 'null' || time=='') {
                    return ''
                } else if (typeof time === 'object') {
                    date = time
                } else {
                    if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
                    time = parseInt(time)
                    }
                    if ((typeof time === 'number') && (time.toString().length === 10)) {
                    time = time * 1000
                    }
                    date = new Date(time)
                }
                const formatObj = {
                    y: date.getFullYear(),
                    m: date.getMonth() + 1,
                    d: date.getDate(),
                    h: date.getHours(),
                    i: date.getMinutes(),
                    s: date.getSeconds(),
                    a: date.getDay()
                }
                const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
                    let value = formatObj[key]
        
                    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
                    if (result.length > 0 && value < 10) {value = '0' + value}
                    return value || 0
                })
                return time_str
            },
            changeAddress(){
                var _this = this;
                sessionStorage.setItem('isModify',2)
                pageFlow(Number(_this.appointment.extra),res => {
                    var res = res.data;
                    if(res.code == 1){
                        sessionStorage.setItem('flowInfo',JSON.stringify(res.data))
                        this.$router.replace({ path:'/CounterAddress'});
                    }else if(res.code == 401){
                        _this.$router.replace({path:'/'})
                    }else if(re.code == 102 || re.code == 103){
                        _this.$router.replace({path:'/examine'})
                    }else if(re.code == 104){
                        _this.$router.go(0)
                    }else{
                        this.$message({
                            message: res.data.msg,
                            type: "warning"
                        });
                    }
                })
                
            },
            returnLinks(){
                 this.$router.replace({ path:'/examine'});
            }
        },
        watch:{

        },
    }
</script>

<style lang="less">
    .verification{
        width: 460px;
        position: relative;
        margin:0 auto;
        padding-top: 40px;
        .verification_title{
            font-size: 20px;
            font-weight: bold;
            line-height: 36px;
        }
        .verification_con{
            font-size: 14px;
            color: @titleColor;
            line-height:23px;
        }
        .verification_list{
            padding-top: 21px;
            li{
                width: 100%;
                padding-bottom: 20px;
                h2{
                    padding-left: 31px;
                    font-size: 16px;
                    color: @404040;
                    line-height: 35px;
                    background-size: 20px auto;
                    background-repeat: no-repeat;
                    background-position: left center;
                }
                h2.ico1{
                    background-image: url(~@/assets/examine05.png);
                }
                h2.ico2{
                    background-image: url(~@/assets/examine06.png);
                }
                .fonts{
                    font-size: 16px;
                    color: @titleColor;
                    padding-left: 43px;
                    line-height: 33px;
                }
                dl{
                    padding-top: 10px;
                    width: 100%;
                    dd{
                        margin: 0;
                        margin-top: 20px;
                        padding:20px 17px 20px 19px;
                        background: url(~@/assets/examine07.png) no-repeat center;
                        background-size: 100% 100%;
                        border-radius:3px;
                        overflow: hidden;
                        cursor: pointer;
                        transition: all 0.3s;
                        .box{
                            padding-right: 15px;
                            display: block;
                            background: url(~@/assets/examine08.png) no-repeat right center;
                            background-size: 10px auto;
                        }
                        .ddTitle{
                            font-size: 20px;
                            color: @fff;
                            line-height:30px;
                        }
                        .ddcongt{
                            font-size: 14px;
                            color: @fff;
                            line-height:24px;
                        }
                    }
                    dd:hover{
                        opacity: 0.8;
                    }
                }
                .divBox{
                    width: 100%;
                    padding:9px 0;
                    margin-top: 30px;
                    border-top:1px solid @e7e6eb;
                    border-bottom:1px solid @e7e6eb;
                    cursor: pointer;
                    .BoxTitle{
                        font-size: 20px;
                        color: @000;
                        line-height:40px;
                        a{font-size: 14px;}
                    }
                    p{
                        font-size: 14px;
                        color: @titleColor;
                        line-height: 21px;
                        padding:7px 0;
                    }
                }
            }
        }
        .mainLandBtns{
            width: 100%;
            text-align: center;
            font-size: 0;
            margin-top: 20px;
            span{
                cursor: pointer;
                width:400px;
                height: 36px;
                line-height: 36px;
                border-radius:3px;
                display: block;
                margin:0 auto;
                text-align: center;
                font-size: 14px;
                transition: opacity 0.3s;

            }
            span:hover{
                opacity: 0.8;
            }
            span.return{
                background: @e7e6eb;
                color: @000;
            }
            span.next{
                background: @hoverColor;
                color: @fff;
            }
        }
    }
</style>